﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataModel
{
    public class ContentTypeList : List<ContentType>
    {

        /// <summary>
        /// Adds the specified n content type.
        /// </summary>
        /// <param name="nContentType">The new content type.</param>
        new public void Add(ContentType nContentType)
        {
            if (!Contains(nContentType.Name))
            {
                base.Add(nContentType);
            }
        }

        /// <summary>
        /// Determines whether this [contains] [the specified name].
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns><c>true</c> if this [contains] [the specified name]</returns>
        public bool Contains(String name)
        {
            foreach (ContentType ct in this)
            {
                if (ct.Name == name)
                {
                    return true;
                }
            }
            return false;
        }

        /// <summary>
        /// Gets the content type with the specified name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>The content type in this list with the specified name.</returns>
        public ContentType GetContentTypeByName(String name)
        {
            foreach (ContentType ct in this)
            {
                if (ct.Name == name)
                {
                    return ct;
                }
            }
            return null;
        }
    }
}
